package WaiBao;

import java.util.Arrays;

public class YaoQiXuan {
    public static void main(String[] args) {
        String[] name = {"凌达乐(班长)","李军军(宣传委员)", "小李(学习委员)","王开支(生活委员)", "李耀虎", "王宝强", "王志宝", "李佳佳", "李浩", "张金一", "李藏难", "张博源",
                "王猛听", "张伟", "李聪同", "陈赫", "张海安", "吕子乔", "张子崔", "王大陆", "李旭旭", "张荣村", "李松岭", "陈美嘉", "张一言", "李江山", "李胜义", "李强值",
                "李大洋", "药奇轩(心理委员)"};//考生本人:药奇轩(心理委员)
        int[] age = {20,20,21,20, 19,21, 19, 20, 19, 19, 18, 20, 18, 20, 18, 19, 21, 19, 18, 20, 19, 19, 20, 19, 20, 21, 20,22, 21, 19};//最后一位：考生年龄:19

        double[] luanxiao1 = {74, 75, 87, 80, 81, 69, 78, 69, 60, 80, 91, 87, 85, 79, 64, 68, 69, 90, 96, 88, 92, 91, 95, 85, 75, 74, 78, 84, 83, 95};
        double[] luanxiao2 = {84, 81, 81, 65, 78, 84, 85, 67, 60, 81, 60, 67, 85, 85, 85, 65, 86, 74, 66, 78, 82, 71, 85, 85, 75, 89, 75, 73, 86, 95};
        double[] luanxiao3 = {80, 84, 74, 65, 89, 75, 69, 64, 80, 60, 97, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 75, 74, 95};


        double yangle1;//代表每个学生的总分
        double yangle2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            yangle1 = luanxiao1[i] + luanxiao2[i] +luanxiao3[i];
//            yangle2 = (yangle1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + yangle1);
//            System.out.println(name[i] + "的平均分为:" + yangle2);
//        }


        double neirong1 = 0,neirong2 = 0;
        double[] kangyuan = new double[30];
//        for (int i = 0; i < 30; i++) {
//            neirong1 = luanxiao1[i] + luanxiao2[i] + luanxiao3[i];
//            neirong2 = ( neirong1 * 1.0) / 3;
//            kangyuan[i] = neirong2;
//        }
//
//        for (int i = 0; i < kangyuan.length - 1; i++) {
//            for (int j = 0; j < kangyuan.length - i - 1; j++) {
//                if (kangyuan[j] < kangyuan[j + 1]) {
//                    double temp =kangyuan[j];
//                    kangyuan[j] = kangyuan[j + 1];
//                    kangyuan[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(kangyuan[i]);
//        }

        double luosi1 = 0,luosi2 = 0,luosi3 = 0;//计算每门课的平均分
        double jaingb1 = 0,jaingb2 = 0, jaingb3 = 0;//计算每门课标准差
        double lage1 = 0, lage2 = 0, lage3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i <luanxiao1.length; i++) {
            sum2+=luanxiao1[i];
        }
        luosi1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+luosi1);
        double Sum = 0;
        for (int i = 0; i < luanxiao2.length; i++) {
            Sum+=luanxiao2[i];
        }
        luosi2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+luosi2);
        double sum = 0;
        for (int i = 0; i <luanxiao3.length; i++) {
            sum+=luanxiao3[i];
        }
        luosi3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+luosi3);


        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < luanxiao1.length; i++) {
            c1+= (luanxiao1[i] -luosi1)*(luanxiao1[i] - luosi1);
        }
        jaingb1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ jaingb1);

        for (int i = 0; i < luanxiao2.length; i++) {
            c2+= (luanxiao2[i] -luosi2)*(luanxiao2[i] - luosi2);
        }
        jaingb2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ jaingb2);

        for (int i = 0; i < luanxiao3.length; i++) {
            c3+= (luanxiao3[i] -luosi3)*(luanxiao3[i] -luosi3);
        }
        jaingb3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+jaingb3);
////
        Arrays.sort(luanxiao1);
        Arrays.sort(luanxiao2);
        Arrays.sort(luanxiao3);
        lage1 =( luanxiao1[14]+luanxiao1[15])*1.0/2;
        lage2 =( luanxiao2[14]+luanxiao2[15])*1.0/2;
        lage3 =( luanxiao3[14]+luanxiao3[15])*1.0/2;
        System.out.println("分析化学的中位数为:"+lage1);
        System.out.println("线性代数的中位数为:"+lage2);
        System.out.println("有机化学学的中位数为:"+lage3);


    }
}
